#ifndef TIMETREEWIDGETITEM_H
#define TIMETREEWIDGETITEM_H 1

#include "TimeTreeWidget.h"

class QPainter;

/**
 * @brief The TimeTreeWidgetHeader class
 * @note 时间刻度、进度条
 */
class TimeTreeWidgetHeader : public TimeTreeItemManager
{
    Q_OBJECT
public:
    explicit TimeTreeWidgetHeader(QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
    ~TimeTreeWidgetHeader();

signals:
    /** 鼠标右键菜单 */
    void signalRightButtonRelease(QPoint pos);

protected:
    // Event handlers
    virtual void mouseReleaseEvent(QMouseEvent *event);
#ifndef QT_NO_WHEELEVENT
    virtual void wheelEvent(QWheelEvent *event);
#endif
    virtual void paintEvent(QPaintEvent *event);

protected:
    QRect _rectTextDelta; // 绘制文本的区域
};

/**
 * @brief The TimeTreeWidgetItem class
 * @note 时间树状结构Item
 */
class TimeTreeWidgetItem : public TimeTreeItemManager
{
    Q_OBJECT

public:
    explicit TimeTreeWidgetItem(QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
    ~TimeTreeWidgetItem();

    /** 设置当前item级数 */
    void setLevelNum(int levelNum) { _iLevelNum = levelNum; }

    /** 设置当前item是否选中 */
    bool isSelected() { return _bIsSelected; }
    void setSelected(bool selected) { _bIsSelected = selected; }

    /** 记录当前ItemVisible是否显示 */
    bool isItemVisible() { return _bItemVisible; }
    void SetItemVisible(bool itemVisible) { _bItemVisible = itemVisible; }

    /** 设置显示id */
    QString getId() { return _strId; }
    void setId(QString strId) { _strId = strId; }

signals:
    void signalClickedSelected(int type);
    void signalDoubleClickedSelected();

protected:
    // Event handlers
    virtual void mouseReleaseEvent(QMouseEvent *event);
    virtual void mouseDoubleClickEvent(QMouseEvent *event);
    virtual void paintEvent(QPaintEvent *event);

    /** 根据Item的级数，渲染不同的元素 */
    void drawLevelElement(QPainter *painter);

protected:
    int _iLevelNum;      // 当前分级数
    bool _bIsSelected;	 // 当前Item是否被选中
    bool _bIsExpend;	 // 如果第一级分支，是否扩展显示
    bool _bItemVisible;     // 当前Item是否显示
    QString _strId;
};

#endif // TIMETREEWIDGETITEM_H
